<html>
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <meta http-equiv="refresh" content="120">
        <title>
        </title>
    </head>
    <body>
        <center>
                <table  border="1" cellspacing="0" cellpadding="0">
                    <caption>订单表</caption>
                        <th>订单id</th>

                        <th>产品名称</th>
                        <th>产品分类名</th>
                        <th>用户购买的数量</th>
                        <th>用户姓名</th>

                        <th>手机<th>
                        <th>email</th>
                        <th>地址</th>

                        <th>留言</th>
                        <th>产品总价</th>
                        <th>订单时间</th>
                        <?php
                        // 页面 url
                        $pageURL = "./dataShow.php";
                        // 获取 cookie 如果没有 则设置 生成必要信息
                        $key0 = "";
                        $key1 = "";
                        if (!isset($_COOKIE['key0'])){
                          $key0 = "v1.0.0";
                          setcookie("key0", "v1.0.0", time()+63072000); // 版本号 v1.0.0
                        }else{
                          $key0 = $_COOKIE['key0'];
                        }
                        if (!isset($_COOKIE['key1'])){
                          $key1 = md5(uniqid().":".mt_rand(1,1000000));
                          setcookie("key1", $key1, time()+63072000); // 用户账号 随机生成
                        }else{
                          $key1 = $_COOKIE['key1'];
                        }

                        // 取得 ip
                        if (getenv("HTTP_CLIENT_IP"))
                        $ip = getenv("HTTP_CLIENT_IP");
                        else if(getenv("HTTP_X_FORWARDED_FOR"))
                        $ip = getenv("HTTP_X_FORWARDED_FOR");
                        else if(getenv("REMOTE_ADDR"))
                        $ip = getenv("REMOTE_ADDR");
                        else
                        $ip = "Unknow";
                        // 判断设备
                        $she_bei = "";
                        $liu_lan_qi = $_SERVER ['HTTP_USER_AGENT'];
                        function is_mobile() {
                          $user_agent = $_SERVER ['HTTP_USER_AGENT'];
                          $mobile_browser = Array (
                              "mqqbrowser", // 手机QQ浏览器
                              "opera mobi", // 手机opera
                              "juc",
                              "iuc", // uc浏览器
                              "fennec",
                              "ios",
                              "applewebKit/420",
                              "applewebkit/525",
                              "applewebkit/532",
                              "ipad",
                              "iphone",
                              "ipaq",
                              "ipod",
                              "iemobile",
                              "windows ce", // windows phone
                              "240×320",
                              "480×640",
                              "acer",
                              "android",
                              "anywhereyougo.com",
                              "asus",
                              "audio",
                              "blackberry",
                              "blazer",
                              "coolpad",
                              "dopod",
                              "etouch",
                              "hitachi",
                              "htc",
                              "huawei",
                              "jbrowser",
                              "lenovo",
                              "lg",
                              "lg-",
                              "lge-",
                              "lge",
                              "mobi",
                              "moto",
                              "nokia",
                              "phone",
                              "samsung",
                              "sony",
                              "symbian",
                              "tablet",
                              "tianyu",
                              "wap",
                              "xda",
                              "xde",
                              "zte"
                          );
                          $is_mobile = false;
                          foreach ( $mobile_browser as $device ) {
                            if (stristr ( $user_agent, $device )) {
                              $is_mobile = true;
                              break;
                            }
                          }
                          return $is_mobile;
                        }
                        if(is_mobile()){
                          $she_bei = "mobile";
                        }else{
                          $she_bei = "pc";
                        }


                          // 向数据库插入
                          // 开DB连接
                          $dbConnection = new PDO('mysql:dbname=firstpanda;host=127.0.0.1;charset=utf8', 'ChromieWang', 'xiaoxinxin0522');
//                          $dbConnection = new PDO('mysql:dbname=dhshop;host=127.0.0.1;charset=utf8', 'root', 'panda123');
                          $dbConnection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
                          $dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

                          //$stmt = $pdo->prepare('SELECT * FROM employees WHERE name = :name');
                          $stmt = $dbConnection->prepare('INSERT INTO fang_wen_ji_lu_biao (cookie_ban_ben,yong_hu_zhang_hao,yong_hu_mi_ma,fang_wen_url,fang_wen_shi_jian,ip,she_bei,liu_lan_qi) VALUES (:cookie_ban_ben,:yong_hu_zhang_hao,:yong_hu_mi_ma,:fang_wen_url,now(),:ip,:she_bei,:liu_lan_qi)');
                          $stmt->execute(array(':cookie_ban_ben' => $key0,':yong_hu_zhang_hao' => $key1,':yong_hu_mi_ma' => $key1,':fang_wen_url' => $pageURL,':ip' => $ip,':she_bei' => $she_bei, ':liu_lan_qi' => $liu_lan_qi));
                          // 关DB连接
                          $dbConnection = null;





                        $root = $_POST['id'];
                        $panda = $_POST['pswd'];

                        if(!($root === "wowCxa72")){ // 如果连接不成功，跳转
                          //header("location:540b28872a58ee03f9cf961520bd2e5f.html");
                          header("location:dshow.php");
                        }
                        if(!($panda === "thisisapassword67x")){
                          header("location:dshow.php");
                        }

//                            $link=mysql_connect("localhost","root","panda123");

                            $link=mysql_connect("127.0.0.1","pandashow","Aoppo13689");
                            if(!$link){ // 如果连接不成功，跳转
                              //header("location:540b28872a58ee03f9cf961520bd2e5f.html");
                              header("location:dshow.php");
                            }
                            mysql_select_db("firstpanda");
                            $exec="SELECT
	ding_dan_biao.ding_dan_id ddid,
	ding_dan_biao.chan_pin_id cpid,
	ding_dan_biao.shu_liang sl,
	ding_dan_biao.xm xingming,
	ding_dan_biao.sj sj,
	ding_dan_biao.em email,
	ding_dan_biao.xx dz,
	ding_dan_biao.ly ly,
	ding_dan_biao.uname uid,
  ISNULL(ding_dan_biao.chuang_jian_shi_jian) cjzt,
date_add(ding_dan_biao.chuang_jian_shi_jian, interval 15 hour) cjsj,
  ISNULL(ding_dan_biao.que_ren_shi_jian) qrzt,
ding_dan_biao.que_ren_shi_jian qrsj,
ISNULL(ding_dan_biao.qu_xiao_shi_jian) qxzt,
ding_dan_biao.qu_xiao_shi_jian qxsj,
ISNULL(ding_dan_biao.fa_huo_shi_jian) fhzt,
ding_dan_biao.fa_huo_shi_jian fhsj,
ISNULL(ding_dan_biao.wan_cheng_shi_jian) wczt,
ding_dan_biao.wan_cheng_shi_jian wcsj,

	chan_pin_biao.chan_pin_ming_cheng cpmc,
	fen_lei_biao.fen_lei_ming flm,
	fen_lei_biao.jia_ge jg,
	(
		fen_lei_biao.jia_ge * ding_dan_biao.shu_liang
	) zongjia
FROM
	ding_dan_biao
LEFT JOIN chan_pin_biao ON ding_dan_biao.chan_pin_id = chan_pin_biao.chan_pin_id
LEFT JOIN fen_lei_biao ON ding_dan_biao.fen_lei_id = fen_lei_biao.fen_lei_id
AND ding_dan_biao.chan_pin_id = fen_lei_biao.chan_pin_id
ORDER BY
	ding_dan_biao.chuang_jian_shi_jian DESC ";
                            mysql_query("set character set 'utf8'");
                            mysql_query("set names 'utf8'");
                            $result=mysql_query($exec);
                            while($rs=mysql_fetch_object($result)){
                                $ddid=$rs->ddid;  // 订单id  **
                                $cpid=$rs->cpid;  // 产品id
                                $sl=$rs->sl; // 用户购买的数量  **
                                $xingming=$rs->xingming; // 用户填写地址的姓名 **
                                $sj=$rs->sj; // 用户填写的手机  **
                                $email=$rs->email; // 用户填写的email **
                                $dz=$rs->dz; // 用户填写的地址  **
                                $ly=$rs->ly; // 用户填写的留言  **
                                $uid=$rs->uid; // 记录的用户id
                                $cpmc=$rs->cpmc; // 产品名称  **
                                $flm=$rs->flm; // 产品分类名  **
                                $jg=$rs->jg; // 产品单价
                                $zongjia=$rs->zongjia; // 产品总价 **
                                $cjsj=$rs->cjsj; // 创建时间 **
                        ?>
                    <tr align="center">

                      <th><?php echo $ddid ?></th>
                      <th><?php echo $cpmc ?></th>
                      <th><?php echo $flm ?></th>
                      <th><?php echo $sl ?></th>
                      <th><?php echo $xingming ?></th>

                      <th><?php echo $sj ?><th>
                      <th><?php echo $email ?></th>
                      <th><?php echo $dz ?></th>

                      <th><?php echo $ly ?></th>
                      <th><?php echo $zongjia ?></th>
                      <th><?php echo $cjsj ?></th>
                </tr>
                <?php
                    }
                    mysql_close();
                ?>
                </table>
        </center>
    </body>
</html>
